#include "mainwindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->resize(600,400);
    this->setWindowTitle("MainWindow");

    QPushButton *OpenButton = new QPushButton("Open NewWindow",this);
    OpenButton->resize(150,50);
    OpenButton->move(250,100);

    QWidget *NewWindow = new QWidget;
    NewWindow->setWindowTitle("NMSL");
    NewWindow->resize(200,300);

    QPushButton *CloseButton = new QPushButton("Close NewWindow",NewWindow);
    CloseButton->resize(150,50);
    CloseButton->move(10,10);

    connect(OpenButton,&QPushButton::clicked,NewWindow,[=](){
        if(NewWindow->isActiveWindow() == false){
            NewWindow->show();
            this->close();
        }
    });

    connect(CloseButton,&QPushButton::clicked,NewWindow,[=](){
        if(NewWindow->isActiveWindow() == true){
            NewWindow->close();
            this->show();
        }
    });

}

MainWindow::~MainWindow()
{
}
